﻿Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Navigation

Partial Public Class MyBlogPage
    Inherits Page

    Private _blogList As List(Of Blog)

    Public Sub New()
        Me.InitializeComponent()
        Me.DataContext = New MyBlogPageViewModel()
    End Sub

    'Executes when the user navigates to this page.
    Protected Overrides Sub OnNavigatedTo(ByVal e As NavigationEventArgs)
        '    '从 MyBlogPageViewModel 获取博客列表
        '    _blogList = CType(Me.DataContext, MyBlogPageViewModel).BlogList
        '    Console.WriteLine("OnNavigatedTo" + _blogList.ToString())
        '    If _blogList Is Nothing OrElse _blogList.Count = 0 Then
        '        Exit Sub
        '    End If
        '    '根据 blogList 渲染 UserControl(MyBlogItem.xaml)
        '    For Each blog In _blogList
        '        Dim myBlogItem As New MyBlogItem()
        '        myBlogItem.DataContext = blog
        '        Me.IC_MyBlogItemList.Items.Add(myBlogItem)
        '    Next
        '如果用户未登录，则跳转到登录页面
        If Application.Current.Resources("UserId") Is Nothing Then
            NavigationService.Navigate(NavigationData.LOGIN_PAGE_URI)
        End If
    End Sub

End Class
